﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Util
{
    public class TimeUtil
    {
        /// <summary>
        /// 获得距离1970-01-01的毫秒数
        /// </summary>
        /// <param name="newDate">时间参数</param>
        /// <returns></returns>
        public static long GetMilliSecond(DateTime newDate)
        {
            DateTime oldDate = new DateTime(1970, 1, 1);
            TimeSpan ts = newDate.ToUniversalTime() - oldDate;
            return (long)ts.TotalMilliseconds;
        }

        public static long GetTimeStampTicks(DateTime newDate) 
        {
            DateTime oldDate = new DateTime(1970, 1, 1);
            TimeSpan ts = newDate.ToUniversalTime() - oldDate;
            return ts.Ticks;
        }
    }
}
